package cn.felord.debezium.controller;

import cn.felord.debezium.VO.DetectRlVO;
import cn.felord.debezium.dao.DetectionRlMapper;
import cn.felord.debezium.utils.TcpClientPusDuan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/test/push")
public class TestController {
    @Value("${zhu1ip}")
    String zhu1ip;
    @Value("${zhu1port}")
    String zhu1port;
    @Value("${zhu2ip}")
    String zhu2ip;
    @Value("${zhu2port}")
    String zhu2port;
    @Autowired
    DetectionRlMapper detectionRlMapper;
    @RequestMapping("/hccm")//GG20HC
    public String hccm()  {
        String s = "00 01 00 00 00 1B 01 10 00 00 00 08 06 47 47 32 30 48 43";//GG20HC
        TcpClientPusDuan.push(zhu1ip,zhu1port,s,false);
        return "hccm";
    }
    @RequestMapping("/hccm1")//GG20HC
    public String hccm1()  {
        String s1 = "06 47 47 32 30 48 43";//GG20HC
        TcpClientPusDuan.push(zhu1ip,zhu1port,s1,false);
        return "hccm";
    }
    @RequestMapping("/go")
    public String go()  {
        DetectRlVO detectRlById = detectionRlMapper.getDetectRlById(1l);
        return detectRlById.toString();
    }
    @RequestMapping("/hi")
    public String hi(String hi)  {
        TcpClientPusDuan.push(zhu1ip,zhu1port,hi,false);
        return hi;
    }
    @RequestMapping("/G3000")
    public String G3000()  {
        String s = "00 01 00 00 00 1B 01 10 00 00 00 08 10 C6 D5 CD A8 47 33 30 30 30 20 47 47 32 30";
        TcpClientPusDuan.push(zhu1ip,zhu1port,s.trim(),false);
        return "普通G3000 GG20";
    }
    @RequestMapping("/bz")
    public String bz()  {
        String s = "00 01 00 00 00 1B 01 10 00 0E 00 24 48 01 68 01 72 00 8C 00 96 00 32 00 46 00 00 00 0A 00 05 00 0A 00 1E 00 23 00 00 00 01 00 28 00 32 00 06 00 08 01 68 01 72 00 A5 00 AF 00 32 00 46 00 00 00 0A 00 05 00 0A 00 1E 00 23 00 00 00 01 00 28 00 32 00 06 00 08";
        TcpClientPusDuan.push(zhu1ip,zhu1port,s,false);
        return "bz";
    }
}
